## Controller Python Script "sigfs_personalize"
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind state=state
##bind subpath=traverse_subpath
##parameters=telefone=None, orgao=None, funcao=None, REQUEST=None
##title=Personalization Handler.

from Products.CMFPlone.utils import transaction_note
from Products.CMFPlone import PloneMessageFactory as _

member=context.portal_membership.getAuthenticatedMember()
member.setProperties(context.REQUEST)
member_context=context.portal_membership.getHomeFolder(member.getId())
context.portal_skins.updateSkinCookie()

if member_context is None:
    member_context=context.portal_url.getPortalObject()

if telefone is None and REQUEST is not None:
    telefone=''
REQUEST.set('telefone', telefone)

if orgao is None and REQUEST is not None:
    orgao=''
REQUEST.set('orgao', orgao)

if funcao is None and REQUEST is not None:
    funcao=''
REQUEST.set('funcao', funcao)

member.setProperties(telefone=telefone, orgao=orgao, funcao=funcao)

tmsg='Edited personal settings for %s' % member.getUserName()
transaction_note(tmsg)

context.plone_utils.addPortalMessage(_(u'Your personal settings have been saved.'))
return state
